/*
    Ingress Calculator
*/

$gov={
  destRes : 75,  //ap to destroy a single resonator
  destLnk : 187, //ap to destroy a single link
  destCtl : 750, //ap to destroy a single control field
  addRes  : 125, //ap to add a single resonator
  addLnk  : 313, //ap to add a single link
  addCtl  : 1250, //ap to add a single control field
  addShld : 150, //ap to add a single shield
  add1stRes : 500, //ap bonus for capturing portal (1st resonator)
  addLstRes : 250 //ap bonus for placing last resonator (8th)
};

$gov.calcDestroy=function(pv_res,pv_lnk,pv_ctl){
    var returnVal=(pv_res*$gov.destRes)+
        (pv_lnk*$gov.destLnk)+
        (pv_ctl*$gov.destCtl);
    return((isNaN(returnVal))?0:returnVal);
};
$gov.calcBuild=function(pv_res,pv_fRes,pv_lRes,pv_lnk,pv_ctl){
    var returnVal=(pv_res*$gov.addRes)+
        (pv_lnk*$gov.addLnk)+
        (pv_ctl*$gov.addCtl)+
        (pv_fRes*$gov.add1stRes)+
        (pv_lRes*$gov.addLstRes);
    return((isNaN(returnVal))?0:returnVal);
};

//attack
  $gov.ptsDestroy=$gov.calcDestroy(240,59,30);//res,link,field

//build
  $gov.ptsBuild=$gov.calcBuild(240,30,30,0,0);//res,first res,last res,link,field


//total
  $gov.ptsTtl=$gov.ptsDestroy+$gov.ptsBuild;
  console.log($gov.ptsTtl);
